package com.houxy.service.impl;

import com.houxy.repository.mapper.NoticeMapper;
import com.houxy.repository.model.entity.Notice;
import com.houxy.service.NoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * @author Hou
 * @date 2019/3/18 15:53
 * @describe：
 */
@Service("noticeService")
public class NoticeServiceImpl implements NoticeService {

    @Autowired
    private NoticeMapper noticeMapper;

    @Override
    public boolean addNotice(Notice notice) {
        notice.setCreateTime(new Date());
        int insert = noticeMapper.insertSelective(notice);
        if (insert > 0) {
            return true;
        }
        return false;
    }

    @Override
    public boolean deleteNotice(int noticeId) {
        int delete = noticeMapper.deleteByPrimaryKey(noticeId);
        if (delete > 0) {
            return true;
        }
        return false;
    }

    @Override
    public Notice findById(int noticeId) {
        return noticeMapper.selectByPrimaryKey(noticeId);
    }

    @Override
    public List<Notice> findAll() {
        return noticeMapper.findAll();
    }

    @Override
    public List<Notice> findAllLimit() {
        return noticeMapper.findLimimt();
    }
}
